<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:a="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich"
                template="layout/template.xhtml">
                       
<ui:define name="body">
    
    <h:messages globalOnly="true" styleClass="message" id="globalMessages"/>

    <h:form id="korisnik" styleClass="edit">
    
        <rich:panel>
            <f:facet name="header">#{korisnikHome.managed ? 'Edit' : 'Add'} Korisnik</f:facet>


            <s:decorate id="imeDecoration" template="layout/edit.xhtml">
                <ui:define name="label">Ime</ui:define>
                <h:inputText id="ime" 
               		   required="true"
                           size="30"
                      maxlength="20"
                          value="#{korisnikHome.instance.ime}">
                    <a:support event="onblur" reRender="imeDecoration" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>

            <s:decorate id="prezimeDecoration" template="layout/edit.xhtml">
                <ui:define name="label">Prezime</ui:define>
                <h:inputText id="prezime" 
               		   required="true"
                           size="30"
                      maxlength="30"
                          value="#{korisnikHome.instance.prezime}">
                    <a:support event="onblur" reRender="prezimeDecoration" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>

            <s:decorate id="jmbgDecoration" template="layout/edit.xhtml">
                <ui:define name="label">Jmbg</ui:define>
                <h:inputText id="jmbg" 
                       required="true"
                          value="#{korisnikHome.instance.jmbg}"
                           size="13">
                    <a:support event="onblur" reRender="jmbgDecoration" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>

            <s:decorate id="adresaDecoration" template="layout/edit.xhtml">
                <ui:define name="label">Adresa</ui:define>
                <h:inputText id="adresa" 
                	   required="true"
                           size="50"
                      maxlength="50"
                          value="#{korisnikHome.instance.adresa}">
                    <a:support event="onblur" reRender="adresaDecoration" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>

            <s:decorate id="pttDecoration" template="layout/edit.xhtml">
                <ui:define name="label">Ptt</ui:define>
                <h:inputText id="ptt" 
                	   required="true"
                          value="#{korisnikHome.instance.ptt}"
                           size="5"
                           maxlength="5"
                           converter="javax.faces.Integer">
                    <a:support event="onblur" reRender="pttDecoration" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>

            <s:decorate id="mestoDecoration" template="layout/edit.xhtml">
                <ui:define name="label">Mesto</ui:define>
                <h:inputText id="mesto" 
                	   required="true"
                           size="50"
                      maxlength="50"
                          value="#{korisnikHome.instance.mesto}">
                    <a:support event="onblur" reRender="mestoDecoration" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>

            <s:decorate id="drzavaDecoration" template="layout/edit.xhtml">
                <ui:define name="label">Drzava</ui:define>
                <h:inputText id="drzava" 
                	   required="true"
                           size="10"
                      maxlength="10"
                          value="#{korisnikHome.instance.drzava}">
                    <a:support event="onblur" reRender="drzavaDecoration" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>

            <s:decorate id="usernameDecoration" template="layout/edit.xhtml">
                <ui:define name="label">Username</ui:define>
                <h:inputText id="username" 
               		   required="true"
                           size="20"
                      maxlength="20"
                          value="#{korisnikHome.instance.username}">
                    <a:support event="onblur" reRender="usernameDecoration" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="passwordDecoration" template="layout/edit.xhtml">
                <ui:define name="label">Password</ui:define>
                <h:inputSecret id="password" 
                	   required="true"
                           size="20"
                      maxlength="20"
                          value="#{korisnikHome.instance.password}">
                    <a:support event="onblur" reRender="passwordDecoration" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputSecret>
            </s:decorate>
        
            <div style="clear:both">
                <span class="required">*</span> 
                obavezna polja
            </div>
            
        </rich:panel>
                
        <div class="actionButtons">

            <h:commandButton id="save" 
                          value="Snimi" 
                         action="#{korisnikHome.persist}"
                       disabled="#{!korisnikHome.wired}"
                       rendered="#{!korisnikHome.managed}"/>  
                          			  
            <h:commandButton id="update" 
                          value="Izmeni" 
                         action="#{korisnikHome.update}"
                       rendered="#{korisnikHome.managed}"/>
                        			  
            <h:commandButton id="delete" 
                          value="Obrisi" 
                         action="#{korisnikHome.remove}"
                      immediate="true"
                       rendered="#{korisnikHome.managed}"/>
                    
            <s:button id="done" 
                   value="Nazad"
             propagation="end"
                    view="/Korisnik.xhtml"
                rendered="#{korisnikHome.managed}"/>
                
            <s:button id="cancel" 
                   value="Odustani"
             propagation="end"
                    view="/#{empty korisnikFrom ? 'KorisnikList' : korisnikFrom}.xhtml"
                rendered="#{!korisnikHome.managed}"/>

        </div>
    </h:form>

</ui:define>

</ui:composition>
